package com.heima;

import com.hankcs.algorithm.AhoCorasickDoubleArrayTrie;

import java.util.List;
import java.util.TreeMap;

public class TestTrie {
    public static void main(String[] args) {
        // Collect test data set
        TreeMap<String, String> map = new TreeMap<String, String>();
        String[] keyArray = new String[]
                {
                        "大麻",
                        "大坏蛋",
                        "大猪",
                        "法轮功"
                };
        for (String key : keyArray) {
            map.put(key, key);
        }
        // Build an AhoCorasickDoubleArrayTrie
        AhoCorasickDoubleArrayTrie<String> acdat = new AhoCorasickDoubleArrayTrie<String>();
        acdat.build(map);
        // Test it
        final String text = "川普爱吸女人，大坏怂，喜欢法论功";
        List<AhoCorasickDoubleArrayTrie.Hit<String>> wordList = acdat.parseText(text);
        System.out.println(wordList.size());
    }
}